<template>
  <div>
    
    <el-form ref="form" :model="formData" label-width="120px" :rules="rules">
      <el-form-item label="">
        <div>{{ formData.deviceid }}({{ formData.lnid }})</div>
      </el-form-item>
      <el-form-item label="分路设备名称" prop="title">
        <el-input
          v-model="formData.title"
          placeholder="分路设备名称"
        ></el-input>
      </el-form-item>
      <el-form-item label="">
        <el-button type="primary" @click="submit">提交</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import {edit} from "@/api/equipment/subdevice.js"
export default {
  props: ['data'],
  watch: {
    data: {
      handler: function (val) {
        this.formData.lnid = val.lnid;
        this.formData.deviceid = val.deviceid;
        this.formData.title = val.title;
      },
      immediate: true,
    },
  },
  data() {
    return {
      formData: {
        lnid: '',
        deviceid: '',
        title: '',
      },
      rules:{
        title:[
          {required:true,message:'请输入分路设备名称',trigger:"blur"}
        ]
      }
    };
  },
  methods: {
    submit() {
      this.$refs.form.validate(valid=>{
        if(valid){
          edit(this.formData).then(res=>{
            this.$emit("success")
          })
        }
      })
    },
  },
};
</script>

<style scoped></style>
